﻿using System;
using System.IO;
using YArchitech.LIB;

namespace YJKPretreatmentModeling
{
	internal class PretreatmentConfigData
	{
		public static string ReadUserData()
		{
			string text = "TH_TITLE";
			string text2 = Product.UserDataLocation;
			text2 += "\\PretreatmentConfigData.txt";
			string result;
			if (!File.Exists(text2))
			{
				PretreatmentConfigData.CreateFile(text, text2);
				result = text;
			}
			else
			{
				string[] array = File.ReadAllLines(text2);
				if (array.Length != 1)
				{
					result = text;
				}
				else
				{
					result = array[0];
				}
			}
			return result;
		}

		public static void WriteUserData(string strFileData)
		{
			if (strFileData == "" || strFileData == null)
			{
				strFileData = "TH_TITLE";
			}
			string text = Product.UserDataLocation;
			text += "\\PretreatmentConfigData.txt";
			PretreatmentConfigData.CreateFile(strFileData, text);
		}

		private static void CreateFile(string strData, string strUserDataPath)
		{
			FileStream fileStream = new FileStream(strUserDataPath, FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			streamWriter.WriteLine(strData);
			streamWriter.Flush();
			streamWriter.Close();
			fileStream.Close();
		}
	}
}
